/*
 * Created on 24-jul-2005
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package org.mushroomdb.engine.costmodel;

import org.mushroomdb.engine.operation.*;
import org.mushroomdb.exception.OptimizerException;


public class CostCalculator {

		private static CostCalculator instance;
		
		private CostCalculator() {
			
		}
		
		public static CostCalculator getInstance() {
			if (CostCalculator.instance == null) {
				CostCalculator.instance = new CostCalculator();
			}
			return CostCalculator.instance;
		}
		
		public ExpectedCost getExpectedCost(RelationOperation relationOperation) throws OptimizerException {
			CostCalculationVisitor costCalculationVisitor = new CostCalculationVisitor();
			relationOperation.accept(costCalculationVisitor);
			ExpectedCost executionPlanExpectedCost = costCalculationVisitor.getExpectedCost();
			
			return executionPlanExpectedCost;
		}
}
